In [1]:
print 'hello, world!'
In [2]:
2 + 2
Out[2]:
In [3]:
5/2
Out[3]:
In [6]:
5/2.0
Out[6]:
In [7]:
print "hello " + " world"
We create a variable fruit and print its data type. type is a built in python function which gives us the type of an object
In [23]:
fruit = 'apple'
print type(fruit)
Now we will assign a numeric value to the variable fruit and see its type
In [22]:
fruit = 10
print 'Fruit is now of type: ' + str(type(fruit))
Let's try assigning it a float value.
In [10]:
fruit = 10.0
print type(fruit)
Python also has built in support for complex numbers
In [24]:
complex_number1 = 10 + 2j
print type(complex_number1)
In [19]:
is_true = True
print is_true
print type(is_true)
In [25]:
2 ** 10
Out[25]:
In [30]:
first_name = 'John'
last_name = 'Doe'
print first_name + ' ' + last_name
In [ ]: